package com.nus.services;

import com.nus.beans.User;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: dell
 * Date: 9/28/12
 * Time: 10:31 PM
 * To change this template use File | Settings | File Templates.
 */
public class FilteringService {
    public List<User> getUsersToAdd(List<User> assignedUsers, List<Integer> newUsers) {
        List<User> usersToAdd = new ArrayList<User>();
        User user;
        for (int userId : newUsers) {
            user = new User();
            user.setUserId(userId);
            if (!assignedUsers.contains(user)) {
                usersToAdd.add(user);
            }
        }
        return usersToAdd;
    }

    public List<User> getUsersToDelete(List<User> assignedUsers, List<Integer> newUsers) {
        List<User> usersToDelete = new ArrayList<User>();
        for (User user : assignedUsers) {
            if (!newUsers.contains(user.getUserId())) {
                usersToDelete.add(user);
            }
        }
        return usersToDelete;
    }
}